#e
#Title[Hu^IuuAT@-Easy-v]
#Text[]
#PlayLevel[Easy]
#ScriptVersion[2]

script_enemy_main {
 let name = "Hu^IuuAT@-Easy-v";

 @Initialize {
  CutIn(KOUMA, name, "", 0, 0, 0, 0);
  SetMovePosition02(GetCenterX, GetCenterY - 50, startWait);
  SetLife(5000);
  SetTimer(80);
  SetScore(1000000);

  LoadGraphic(img);
  SetTexture(img);
  SetGraphicRect(64, 0, 128, 64);

  LoadUserShotData(GetCurrentScriptDirectory~"shot_All.txt");

  TMain;
 }

 @MainLoop {
  SetCollisionA(GetX, GetY, 12);

  yield;
 }

 @DrawLoop {
  DrawGraphic(GetX, GetY);
 }

 @Finalize {
  DeleteGraphic(img);
 }

 task TMain {
  yield;

  wait(startWait);
  TMove;
  TTalismanShot;
  TRandomShot;
 }

 task TMove {
  yield;

  loop {
   SetMovePositionRandom01(50, 50, 0.5, GetCenterX - 80, GetCenterY - 130,
                           GetCenterX + 80, GetCenterY + 30);
   wait(240);
  }
 }

 task TTalismanShot {
  let speed = 1;
  let angle = atan2(GetPlayerY - GetY, GetPlayerX - GetX) - 45;
  let count = 0;
  yield;

  loop {
   loop(3) {
    loop(8) {
     CreateShot01(GetX, GetY, speed, angle, 89, 0);
     angle += 10;
    }
    count += 1;
    speed += 0.4;

    if(count == 1 || count == 2) {
     angle -= 10 * 8;
    }
    if(count == 3) {
     count = 0;
    }

    wait(5);
   }
   speed = 1;
   wait(40);
  }
 }

 task TRandomShot {
  let angle = 0;
  yield;

  loop {
   wait(240);
   angle = rand(90, 270);
   loop(5) {
    loop(4) {
     CreateShot01(GetX, GetY, rand(0.3, 1), angle + rand(-30, 30), rand_int(9, 16), 0);
     CreateShot01(GetX, GetY, rand(0.3, 1), angle + rand(-30, 30), rand_int(25, 32), 0);
    }
    CreateShot01(GetX, GetY, rand(0.3, 1), angle + rand(-30, 30), rand_int(165, 172), 0);
   }
  }
 }

#include_function ".\CN[ht@C.txt"

}